package com.hoshiicloud.saleorder.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hoshiicloud.saleorder.dto.DispatchBillAndDetailDTO;
import com.hoshiicloud.saleorder.entity.OrderInfo;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 * 订单信息 Mapper 接口
 * </p>
 *
 * @author zhangshuhu
 * @since 2019-06-03
 */
public interface OrderInfoMapper extends BaseMapper<OrderInfo> {

    /**
     * 查询商品购买记录
     *
     * @param page 分页参数
     * @param wrapper 查询条件
     * @return Response<Page < Map < String, Object>>>
     */
    Page<Map<String, Object>> queryOrdersWithUserInfo(Page page, @Param("ew") QueryWrapper<OrderInfo> wrapper);

    List<Map<String, Object>> multiConditionBranchOrders(@Param("maps") Map<String, Object> branchOrderQueryParam,
            Page page);

    List<Map<String, Object>> multiConditionBranchOrders(@Param("maps") Map<String, Object> branchOrderQueryParam);

    String selectBaseSpuCategoryId(@Param("categoryId") String categoryId);

    List<Map<String, Object>> selectExportExcelMessage(@Param("maps") Map<String, Object> branchOrderQueryParam);

    /**
     * 根据扩展spu主键组查询销售数量
     *
     * @param wrapper 查询条件
     * @return List<Map < String, Object>>
     */
    List<Map<String, Object>> selectSalesCountBySpuIds(@Param("ew") QueryWrapper<OrderInfo> wrapper);

    /**
     * 根据总店分组查询已售数量
     *
     * @param wrapper 查询参数
     * @return List<Map < String, Object>>
     */
    List<Map<String, Object>> selectSalesCountGroupByStorePid(@Param("ew") QueryWrapper<OrderInfo> wrapper);

    /**
     * 按店铺分组获取店铺粉丝数和购买指数
     *
     * @param queryWrapper 查询参数
     * @return List<Map < String, Object>>
     */
    List<Map<String, Object>> getStoreFansAndBuyExponentGroupById(@Param("ew") QueryWrapper<OrderInfo> queryWrapper);

    /**
     * 根据这些条件查询出, 对应的出货单
     *
     * @param dispatchBillAndDetailDTO 查询条件
     * @return Map
     */
    List<Map<String, Object>> selectDispatchBillDetail(
            @Param("qw") DispatchBillAndDetailDTO dispatchBillAndDetailDTO);
}
